package com.mdlib.helper.base;

import com.ljlib.core.base.BaseFragment;
import com.mdlib.helper.ui.dialog.HelperWaitDialog;

import rx.Subscription;
import rx.subscriptions.CompositeSubscription;

/**
 * Created by librabin on 16/12/13.
 */

public abstract class BaseAppFragmentV2 extends BaseFragment {


    public HelperWaitDialog helperWaitDialog;

    public void startLoadingDialog(boolean isblack) {
        helperWaitDialog = new HelperWaitDialog(getActivity(), isblack);
        helperWaitDialog.show();
    }


    public void stopLoadingDialog() {

        if (helperWaitDialog != null) {
            helperWaitDialog.close();
        }
    }


    @Override
    public void onDestroyView() {
        unSubscribe();
        super.onDestroyView();
    }


    private CompositeSubscription compositeSubscription;

    public void addSubscribe(Subscription subscription) {
        if (compositeSubscription == null) {
            compositeSubscription = new CompositeSubscription();

        }
        compositeSubscription.add(subscription);
    }

    public void unSubscribe() {
        if (compositeSubscription != null) {
            compositeSubscription.unsubscribe();
            compositeSubscription = null;
        }
    }



}
